package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsPermissionMapper;
import com.qf.pojo.DtsPermission;
import com.qf.service.DtsPermissonService;
import org.omg.CORBA.StringHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Service
public class DtsPermissonServiceImpl implements DtsPermissonService {
    @Autowired
    DtsPermissionMapper permission;
    @Override
    public Set<String> findByRoleIds(Integer[] roleIds) {
        LambdaQueryWrapper<DtsPermission>wrapper=new LambdaQueryWrapper<>();
        wrapper.in(DtsPermission::getRoleId,roleIds).select(DtsPermission::getPermission);
        List<DtsPermission> permissions=permission.selectList(wrapper);
        Set<String> perms=new HashSet<>();
        for (DtsPermission dtsPermission : permissions) {
            perms.add(dtsPermission.getPermission());
        }
        return perms;
    }
}
